<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
    body {
        margin: 0;
      }
      .bg {
        width: 100%;
        height: 400px;
        background: #fff;
        background-attachment: fixed;
        background-size: 100%;
      }
      .bg1 {
        background-image: url(./img/1.jpg);
      }
      .bg2 {
        background-image: url(./img/2.jpg);
      }
      .bg3 {
        background-image: url(./img/3.jpg);
      }
      .bg4 {
        background-image: url(./img/4.jpg);
      }
    </style>
</head>
<body>
    <div class="bg"></div>
    <div class="bg bg1"></div>
    <div class="bg"></div>
    <div class="bg"></div>
    <div class="bg bg2"></div>
    <div class="bg"></div>
    <div class="bg bg3"></div>
    <div class="bg"></div>
    <div class="bg bg4"></div>
    <div class="bg"></div>
    <script src="js/jquery-1.12.4.js"></script>
    <script>
      (function($){
          $(function(){
              var top=0;
              var y=0;
              $(document).on('scroll',function(){
                 var _top = $(this).scrollTop();
                 if(_top>top){
                     y-=2
                 }else{
                     y+=2
                 }
                 $('.bg').css('backgroundPositionY',y)
                 top = _top
              })
          })
      })(jQuery)
    
    </script>
</body>
</html>